<template>
  <view class="list">
    <none-data v-if="listData.length === 0" />
    <view class="content" v-if="listData.length !== 0">
      <orderItem
        v-for="item in listData"
        :key="item"
        :orderItem="item"
        @checkedChange="hendelOrderChange"
      ></orderItem>
      <view class="tail" v-if="listData.length !== 0">
        {{ tailText }}
      </view>
    </view>
  </view>
</template>

<script setup>
import { getLeaseOrderListApi } from "@/package_property/pages/api/life-services.js";
import { onShow } from "@dcloudio/uni-app";
import orderItem from "../components/order-item/order-item.vue";
import { ref } from "vue";
import { customNav } from "../../../utils/customNav";
const pageData = ref({
  page: 1,
  size: 10,
  payStatus: 0,
});

const listData = ref([]);
const tailText = ref("");
async function getLeaseOrderList() {
  const res = await getLeaseOrderListApi(pageData.value);
  const { code, data } = res || {};
  if (code == 200) {
    console.log(data);
    listData.value = listData.value.concat(data.records);
    if (listData.value == data.total) {
      tailText.value = "下滑加载更多";
    } else {
      tailText.value = "没有更多内容";
    }
  }
}
function hendelOrderChange(item) {
  console.log(item);
  customNav(`x?id=${item.orderId}`);
}
onShow(() => {
  listData.value = [];
  pageData.value.page = 1;
  getLeaseOrderList();
});
</script>

<style lang="less" scoped>
.list {
  .content {
    background-color: #ffffff;
    padding: 31rpx 31rpx;
  }
}
</style>